//
// Created by iroan on 18-6-15.
//
#include "matrix_1d.h"
/**
 * 功能：实现一维矩阵的减法和乘法
 * @return
 */

vector<float> add(vector<float> v1,vector<float> v2){
    if(v1.size() != v2.size()){
        return vector<float >(0);
    }
    vector<float > res(v1.size());
    for(int index = 0; index < v1.size(); index++){
        res[index] = v1[index] + v2[index];
    }
    return res;
}

vector<float> sub(vector<float> v1,vector<float> v2){
    if(v1.size() != v2.size()){
        return vector<float >(0);
    }
    vector<float > res(v1.size());
    for(int index = 0; index < v1.size(); index++){
        res[index] = v1[index] - v2[index];
    }
    return res;
}

vector<float> mul(vector<float> v1,vector<float> v2){
    if(v1.size() != v2.size()){
        return vector<float >(0);
    }
    vector<float > res(v1.size());
    for(int index = 0; index < v1.size(); index++){
        res[index] = v1[index] * v2[index];
    }
    return res;
}

